﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;

namespace QLHPHP
{
    /// <summary>
    /// Class ve huyện
    /// </summary>
    public static class Huyen
    {
        /// <summary>
        /// Lay danh sach huyen
        /// </summary> 
        /// <returns></returns
        public static DataTable LayDSHuyen()
        {
            DbCommand comm = DataAccess.CreateCommand();
            comm.CommandText = "GetDistrict";
            return DataAccess.ExecuteSelectCommand(comm);
        }

        /// <summary>
        /// Lay danh sach tinh
        /// </summary> 
        /// <returns></returns
        public static DataTable LayDSTinh()
        {
            DbCommand comm = DataAccess.CreateCommand();
            comm.CommandText = "GetTinh";
            return DataAccess.ExecuteSelectCommand(comm);
        }

        /// <summary>
        /// Lay danh sach huyen theo ma tinh
        /// </summary>
        /// <param name="MaKhoa"></param>
        /// <returns></returns>
        public static DataTable LayDSHuyenTheoMaTinh(string MaTinh)
        {
            DbCommand comm = DataAccess.CreateCommand();
            comm.CommandText = "GetDistrictByIdProvince";

            DbParameter param = comm.CreateParameter();
            param.ParameterName = "@MaTinh";
            param.DbType = DbType.String;
            param.Value = MaTinh;
            comm.Parameters.Add(param);

            return DataAccess.ExecuteSelectCommand(comm);
        }
    }
}
